package org.artifact.xls.convert.type;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

public class JavaTypeConvert extends AbstractTypeConvert {
    private static final Log log = LogFactory.get(JavaTypeConvert.class);
    @Override
    public String convert(String type,boolean baseType) {
        String convertType = "";
        switch (type){
            case "int":
                convertType = baseType ? "int" : "Integer";
                break;
            case "ints":
                convertType = baseType ? "int[]" : "Integer[]";
                break;
            case "intss":
                convertType = baseType ? "int[][]" : "Integer[][]";
                break;
            case "str":
                convertType = baseType ? "String" : "String";
                break;
            case "strs":
                convertType = baseType ? "String[]" : "String[]";
                break;
            case "strss":
                convertType = baseType ? "String[][]" : "String[][]";
                break;
            case "map":
                convertType = baseType ? "HashMap" : "HashMap";
                break;
            case "list":
                convertType = baseType ? "ArrayList" : "ArrayList";
                break;
            case "json":
                convertType = baseType ? "JsonObject" : "JsonObject";
                break;
            case "txt":
                convertType = "String";
                break;
            default:
                convertType = type;
                log.debug("Error type {}",type);
                break;
        }
        return convertType;
    }
}
